package week01

// 141. 环形链表
// https://leetcode-cn.com/problems/linked-list-cycle/

// 快慢指针

func hasCycle(head *ListNode) bool {
	var quick, slow = head, head
	for quick != nil && quick.Next != nil {
		quick = quick.Next.Next
		slow = slow.Next
		if quick == slow {
			return true
		}
	}
	return false
}

type ListNode struct {
	Val int
	Next *ListNode
}